package com.example.stumanager.admin;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;

import com.example.stumanager.R;
import com.example.stumanager.adapter.PayAdapter;
import com.example.stumanager.database.PaySql;
import com.example.stumanager.entity.PayEntity;

import java.util.ArrayList;

/**
 * 缴费信息
 */
public class AdminPayPage extends AppCompatActivity {
    ListView list;
    Button re;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.admin_pay_page);
        list=findViewById(R.id.list);
        re = findViewById(R.id.re);
        re.setOnClickListener(view -> finish());
    }

    @Override
    protected void onStart() {
        super.onStart();
        set();
    }
    void set(){
        PaySql db=new PaySql(this);
        ArrayList array=db.getAll();

        PayAdapter adapter=new PayAdapter(AdminPayPage.this,R.layout.layout_jiaofei,array);
        list.setAdapter(adapter);
        list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                String s=( (PayEntity)array.get(i)).getName();
                Toast.makeText(AdminPayPage.this, "姓名："+s, Toast.LENGTH_SHORT).show();
            }
        });
    }
}